package com.starfactory.customer.controller;

import com.starfactory.common.shared.ResponseInfo;
import com.starfactory.customer.api.AddCustomApi;
import com.starfactory.customer.shared.dto.CustomUserBo;
import com.starfactory.customer.shared.dto.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class AddCustomApiController {
  @Autowired
  private AddCustomApi addCustomApi;

  @PostMapping("test/api/addCustomApiApiFunction")
  public ResponseInfo<String> addCustomApiApiFunction(@RequestBody CustomUserBo customUserBo) {
    Result<String> result = addCustomApi.addCustomApiApiFunction(customUserBo);
    if (result.getCode() == 200) {
      return ResponseInfo.success(result.getData());
    } else {
      return ResponseInfo.fail(result.getCode().toString(), result.getMessage());
    }
  }
}